package com.demo.mqtt.zigbee.entity.po.WaveUpload;

import com.demo.mqtt.zigbee.entity.po.StHead;
import javolution.io.Struct;
import lombok.extern.slf4j.Slf4j;

import java.nio.ByteOrder;

/**
 * @program: mqtt
 * @description: 波形上传
 * @author: liuYunKai
 * @create: 2021-03-29 10:13
 */
@Slf4j
public class WaveUpload  extends Struct {
    public final StHead head = inner(new StHead());

    /**
     * sn
     */
    public final UTF8String SN = new UTF8String(10);

    /**
     * 波形数据时间
     */
    public final Unsigned8[] waveTime = array(new Unsigned8[7]);

    /**
     * 波形方向
     */
    public final Unsigned8 waveDir = new Unsigned8();

    /**
     * 波形类型
     */
    public final Unsigned8 waveType = new Unsigned8();

    /**
     * 波形状态
     */
    public final Unsigned8 waveState = new Unsigned8();


    /**
     * 波形长度
     */
    public final Unsigned8 waveLen = new Unsigned8();

    /**
     * 转换系数
     */
    public final Float32 waveCoe = new Float32();

    /**
     * 波形分析频率
     */
    public final Unsigned16 waveFreq = new Unsigned16();

    /**
     * 本报波形数据长度
     */
    public final Unsigned32 length = new Unsigned32();

    /**
     * 波形数据
     */
    public final Float32[] DATA = array(new Float32[480]);

    /**
     * 一定要加上这个，不然会出现对齐的问题
     * @return
     */
    @Override
    public boolean isPacked() {
        return true;
    }

    /**
     * 设置大小端
     * @return
     */
    @Override
    public ByteOrder byteOrder() {
        return ByteOrder.LITTLE_ENDIAN;
//        return super.byteOrder();
    }

}
